/**
 * @project_name staff_vehicle
 * @package_name com.ssh.ser.admin
 * @desc TODO
 * @param
 * @author jack
 * @date 2013-4-25
 * @time 下午7:21:07
 */
package com.ssh.ser.admin;

import com.ssh.dao.CardDAOI;
import com.ssh.entity.Card;

/**
 * @author jack
 *
 */
public class CardManageSerImpl implements CardManageSerI {
	private CardDAOI cardDAOI;

	/*
	 * (non-Javadoc)
	 *
	 * @see com.ssh.ser.admin.CardManageSerI#newAddCard(com.ssh.entity.Card)
	 */
	@Override
	public Card newAddCard(Card card) {
		// TODO Auto-generated method stub

		try {
			cardDAOI.addCard(card);
		} catch (Exception e) {
			return null;
		}

		return card;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see com.ssh.ser.admin.CardManageSerI#updateCard(com.ssh.entity.Card)
	 */
	@Override
	public Card updateCard(Card card) {
		// TODO Auto-generated method stub
		try {
			return cardDAOI.updateByCard(card);
		} catch (Exception e) {
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see com.ssh.ser.admin.CardManageSerI#viewCard(java.lang.String)
	 */
	@Override
	public Card viewCard(String cardId) {
		// TODO Auto-generated method stub
		try {
			return cardDAOI.queryById(cardId);
		} catch (Exception e) {
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see com.ssh.ser.admin.CardManageSerI#delCard(java.lang.String)
	 */
	@Override
	public int delCard(String cardId) {
		// TODO Auto-generated method stub
		try {
			cardDAOI.deleteById(cardId);
		} catch (Exception e) {
			return 0;
		}
		return 1;
	}

	/**
	 * @return the cardDAOI
	 */
	public CardDAOI getCardDAOI() {
		return cardDAOI;
	}

	/**
	 * @param cardDAOI
	 *            the cardDAOI to set
	 */
	public void setCardDAOI(CardDAOI cardDAOI) {
		this.cardDAOI = cardDAOI;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see com.ssh.ser.admin.CardManageSerI#editCard(com.ssh.entity.Card)
	 */
	@Override
	public Card editCard(Card card) {
		// TODO Auto-generated method stub
		try {
			return cardDAOI.updateByCard(card);
		} catch (Exception e) {
			return null;
		}
	}

}
